<script setup>
import { ref,reactive, nextTick,onActivated,getCurrentInstance,onMounted, watch  } from 'vue'; 
import { useRoute,useRouter } from 'vue-router';
import { ElMessage,ElMessageBox  } from 'element-plus';
import { newArea } from "@/utils/area.js";
const seachTable = ref(null);
const route = useRoute();
const router = useRouter();
const instance = getCurrentInstance();

// 新增编辑回退时候刷新列表
onActivated(()=>{
    let closeTagName = sessionStorage.getItem('closeTagName');
    console.log(closeTagName,'closeTagName');
    if(closeTagName == 'pharmacistManageEdit'){
        seachTable.value.handlerSearch();
        
    }else if(closeTagName == 'pharmacistManageAdd'){
        seachTable.value.initSearch();
    }
    instance.proxy.$forceUpdate();
    sessionStorage.removeItem('closeTagName');
})


// 跳转到门店逻辑
const goDoorManege = () => {
  console.log('llllll');
}

const childrenData = ref([]);
const expandLoading = ref([]);

const expandChange = (row)=>{
  // console.log('zhixingle ');
  //   let tableIndex = tableData.value.findIndex(value=>{
  //       return value.uuid  == row.uuid;
  //   })
  //   expandLoading.value[tableIndex] = true;
  //   setTimeout(()=>{
      
  //       childrenData.value = [
  //           {
  //             date: '2016-05-03',
  //             name: 'Tom',
  //             address: 'No. 189, Grove St, Los Angeles',
  //           },
  //           {
  //             date: '2016-05-02',
  //             name: 'Tom',
  //             address: 'No. 189, Grove St, Los Angeles',
  //           },
 
  //       ]
  //       expandLoading.value[tableIndex] = false;
  //       console.log(childrenData,'childrenData');
  //   })
}

const formInline = ref([
    {
      type: "input",
      prop: "name",
      placeholder: "商户名称/ID",
      label: "",
      model: "",
    },
  
])


const tableConfig = ref([
    {
      prop: "doctorNumberCode",
      label: "商品名称",
      width:410
    },
    {
      prop: "name",
      label: "总库存",
      width:410
    },
    {
      prop: "mobile",
      label: "订单占用",
      width:410
    },
    {
      prop: "type",
      label: "可售库存",
      width:410
    }
]);
const tableLoading = ref(false)
const totalPage = ref(0)
const tableData = ref([]);


const handlerSearch = async (formInline)=>{
    tableLoading.value = true;
    try{
        
        totalPage.value = 100;
        tableData.value = [
            {
                "doctorNumberCode": "YS000299",
                "type": "审方",
                "name": "12313",
                "mobile": "18207123212",
                "idCard": "",
                "frontUrl": "https://static.91medicine.net/images/20230919/2930e77d-fba7-4a7e-bbc4-f6815eca5a6d.jpg",
                "headUrl": "https://static.91medicine.net/images/20230919/f6159f8e-c44a-43cc-ae5c-3ddfc659cd7a.jpg",
                "introduce": "3123",
                "institutions": "九为（浙江）网络科技有限公司",
                "certificateUrl": "https://static.91medicine.net/images/20230919/d5e597c3-1c76-4646-a843-03b0b8686a03.jpg",
                "certificateNo": "312312",
                "titleValue": "",
                "uuid": "8a69c4628aab7785018aac0eb31f0004",
                "state": 1,
                "sfdaDoctorType": "1",
                "storeLocationUuid": "",
                "source": "3"
            },
            {
                "doctorNumberCode": "YS000298",
                "type": "审方",
                "name": "63443",
                "mobile": "18205859721",
                "idCard": "1231",
                "frontUrl": "https://static.91medicine.net/images/20230919/a17280e1-702b-4489-97b5-91aed2b7e8ce.jpg",
                "headUrl": "https://static.91medicine.net/images/20230919/c5977a4f-feaf-4bc0-aaff-b61c88a13154.jpg",
                "introduce": "31231",
                "institutions": "九为（浙江）网络科技有限公司",
                "certificateUrl": "https://static.91medicine.net/images/20230919/8564c2ed-3df7-41c2-b8ad-e41b79367ca6.jpg",
                "certificateNo": "312312",
                "titleValue": "",
                "uuid": "8a69c4628aab7785018aac0a6a070000",
                "state": 1,
                "sfdaDoctorType": "1",
                "storeLocationUuid": "",
                "source": "3"
            },
            {
                "doctorNumberCode": "YS000297",
                "type": "咨询",
                "name": "谢362",
                "mobile": "18042518903",
                "idCard": "511024199911211291",
                "frontUrl": "https://static.91medicine.net/images/20230906/69c03021-0a22-4f7d-98a0-b7ec15733e4b.jpg",
                "headUrl": "https://static.91medicine.net/images/20230906/91ef9b58-9fb6-4adb-a964-6311c9d53ba3.jpg",
                "introduce": "",
                "institutions": "宁波市镇海华美星辰健康大药房有限公司",
                "certificateUrl": "https://static.91medicine.net/images/20230906/2e1ecf44-8607-4945-87b1-20dbe25eca50.jpg",
                "certificateNo": "201291",
                "titleValue": "",
                "uuid": "8a69c3d18a4f762d018a683d280c000c",
                "state": 1,
                "sfdaDoctorType": "2",
                "storeLocationUuid": "71345f78c1e4da48e4edc5347df4d2e7",
                "source": "3"
            },
            {
                "doctorNumberCode": "YS000296",
                "type": "咨询,审方",
                "name": "测试机2",
                "mobile": "18069132578",
                "idCard": "420101197701283253",
                "frontUrl": "https://static.91medicine.net/images/20230905/f58659b8-8e02-44ab-b419-59f673c01571.png",
                "headUrl": "https://static.91medicine.net/images/20230905/1a3a3e72-baf7-40f9-a8d9-19bafe3e0abf.png",
                "introduce": "",
                "institutions": "九为（浙江）网络科技有限公司",
                "certificateUrl": "https://static.91medicine.net/images/20230905/07a53eab-2b04-4898-b99b-6e4dbcdc70e3.png",
                "certificateNo": "353453",
                "titleValue": "",
                "uuid": "8a69c3d18a4f762d018a645176630007",
                "state": 1,
                "sfdaDoctorType": "1",
                "storeLocationUuid": "",
                "source": "3"
            },
            {
                "doctorNumberCode": "YS000295",
                "type": "咨询",
                "name": "储伟军",
                "mobile": "13957418736",
                "idCard": "330226197710216395",
                "frontUrl": "https://static.91medicine.net/images/20230831/78d8e1cc-d522-4568-bceb-6ecdee85df10.jpg",
                "headUrl": "https://static.91medicine.net/images/20230831/089aa8f3-ff87-4d1d-8a1a-4feca7497638.jpg",
                "introduce": "",
                "institutions": "九为（浙江）网络科技有限公司",
                "certificateUrl": "https://static.91medicine.net/images/20230831/05fa293d-2a38-436f-8e4d-51250b0731ce.jpg",
                "certificateNo": "330207",
                "titleValue": "",
                "uuid": "8a69c3518a406975018a493e38740006",
                "state": 1,
                "sfdaDoctorType": "1",
                "storeLocationUuid": "",
                "source": "3"
            },
            {
                "doctorNumberCode": "YS000294",
                "type": "咨询",
                "name": "陈",
                "mobile": "15717031390",
                "idCard": "362330197809092019",
                "frontUrl": "https://static.91medicine.net/images/20230829/9340326e-5445-4e8c-976f-86f0ecc9b038.jpeg",
                "headUrl": "https://static.91medicine.net/images/20230829/c1e5a62d-92c3-494c-ba7f-f785f8aa4d6f.jpg",
                "introduce": "...",
                "institutions": "宁波市镇海福兴大药房",
                "certificateUrl": "https://static.91medicine.net/images/20230829/3bffc669-cd51-483c-8d7b-d317611e07dd.jpeg",
                "certificateNo": "211321",
                "titleValue": "",
                "uuid": "8a69c3518a406975018a407ecc250001",
                "state": 1,
                "sfdaDoctorType": "2",
                "storeLocationUuid": "a05146b4a2b1c6bc684d245b98e96511",
                "source": "3"
            },
            {
                "doctorNumberCode": "YS000293",
                "type": "咨询",
                "name": "叶叶",
                "mobile": "15167049206",
                "idCard": "362330197808082011",
                "frontUrl": "https://static.91medicine.net/images/20230825/80099690-2ed3-41ab-b910-6021f19e0556.jpeg",
                "headUrl": "https://static.91medicine.net/images/20230825/5c70356a-4288-4bd2-a1f9-2c8d48ac5cdc.jpeg",
                "introduce": "8年药师执业经验,职业与镇海一心辰大药房",
                "institutions": "宁波市镇海诚普大药房",
                "certificateUrl": "https://static.91medicine.net/images/20230825/344e9e1d-0504-41ef-b126-36b02fd4a1e8.jpeg",
                "certificateNo": "665544",
                "titleValue": "",
                "uuid": "8a69c46c8a214525018a2bba237d0000",
                "state": 1,
                "sfdaDoctorType": "2",
                "storeLocationUuid": "998029f98812d5506d57299f4e049420",
                "source": "3"
            },
            {
                "doctorNumberCode": "YS000292",
                "type": "咨询",
                "name": "傅俊杰",
                "mobile": "15257492356",
                "idCard": "330821199711081410",
                "frontUrl": "https://static.91medicine.net/images/20230810/37a6ac25-077d-4c82-b644-3088f1acaf39.jpg",
                "headUrl": "https://static.91medicine.net/images/20230810/081575f3-08f2-4967-869a-bf9322c6d049.png",
                "introduce": "从业 8 年经验",
                "institutions": "宁波市镇海诚普大药房",
                "certificateUrl": "https://static.91medicine.net/images/20230810/b02c3f58-f0a3-4664-b42c-13a8c2c4d62a.jpg",
                "certificateNo": "011231",
                "titleValue": "",
                "uuid": "8a69c3d989d95be30189dd6463c0000d",
                "state": 1,
                "sfdaDoctorType": "2",
                "storeLocationUuid": "998029f98812d5506d57299f4e049420",
                "source": "3"
            },
            {
                "doctorNumberCode": "YS000291",
                "type": "咨询",
                "name": "马秀卿",
                "mobile": "18758550852",
                "idCard": "330724199412136921",
                "frontUrl": "https://static.91medicine.net/images/20230810/80cad9b3-1d39-4ecf-928d-1c18226c378f.jpg",
                "headUrl": "https://static.91medicine.net/images/20230810/e43aa1ae-3344-40be-8ca0-8b594d9261b8.png",
                "introduce": "从业 12 年经验",
                "institutions": "九为（浙江）网络科技有限公司",
                "certificateUrl": "https://static.91medicine.net/images/20230810/eefe94f2-cc38-4747-8619-0d9b3f992ecc.jpg",
                "certificateNo": "205148",
                "titleValue": "",
                "uuid": "8a69c3d989d95be30189dd29ba3c0000",
                "state": 1,
                "sfdaDoctorType": "1",
                "storeLocationUuid": "8a69c3d989d95be30189dd29bb330002",
                "source": "3"
            },
            {
                "doctorNumberCode": "YS000289",
                "type": "咨询",
                "name": "柯洁",
                "mobile": "15168245310",
                "idCard": "110101200203079198",
                "frontUrl": "https://static.91medicine.net/images/20230718/923b9a39-e95a-4aa7-8c12-2d93645886fa.png",
                "headUrl": "https://static.91medicine.net/images/20230718/3c5bea36-347a-4def-8b7c-17353dcb3470.png",
                "introduce": "从事骨科临床、科研工作40余年",
                "institutions": "大剧院",
                "certificateUrl": "https://static.91medicine.net/images/20230718/a407179b-6eb2-468a-a2bc-0e3068ed9af9.png",
                "certificateNo": "100861",
                "titleValue": "",
                "uuid": "8a69c44e89617fe9018966ca88eb000e",
                "state": 1,
                "sfdaDoctorType": "1",
                "storeLocationUuid": "8a69c44e89617fe9018966ca895a0010",
                "source": "3"
            }
        ];
        tableLoading.value = false;
    }catch(e){
        tableLoading.value = false;
    }
}



</script>
<template>
    <div class="page-content">
        <SeachTable 
          :tableType="1"
          ref="seachTable"
          rowKey="uuid"
          :forms="formInline"
          :btnLefts="btnLefts"
          :btnRights="btnRights"
          :tableLoading="tableLoading"
          :tableConfig="tableConfig"
          :tableData="tableData"
          :totalPage="totalPage"
          :tableExpand="true"
          @handlerSearch="handlerSearch"
          @expandChange="expandChange"
        >
        <template #expandSlot="{ row, index }" >
                <div v-loading="expandLoading[index]" style="width:100%;box-sizing:border-box;padding:0 12px;">
                  <div class="nest-box">
                    <div class="nest-table">批号：16516516516</div>
                    <div class="nest-table">5</div>
                    <div class="nest-table" style="padding-left:23px">5</div>
                    <div class="nest-table" style="padding-left:23px">5</div>
                  </div>
                  <div class="nest-box">
                    <div class="nest-table">批号：16516516516</div>
                    <div class="nest-table" >5</div>
                    <div class="nest-table" style="padding-left:23px">5</div>
                    <div class="nest-table" style="padding-left:23px">5</div>
                  </div>
                </div>
            </template>
        </SeachTable>
    </div>
</template>


<style lang="less" scoped>
  .nest-box{
    display: flex;
    margin-left: 40px;
    .nest-table{
        width: 410px;
        padding: 16px;
        box-sizing: border-box;
        color: #222222;
        font-family: "PingFang SC";
        font-size: 14px;
        font-style: normal;
        font-weight: 400;
        line-height: 14px;
    }
  }
</style>
